package com.zy.tools.appletsTools;

import net.sourceforge.pinyin4j.PinyinHelper;
import org.springframework.stereotype.Component;

@Component
public class PinYinTool {

    /** 第一个汉字首字母大写
     * @author 小宁
     * @date 2021-04-05 12:47
     * @param str
     * @return java.lang.String
     */
    public String getPinYinHeadChar(String str) {
        StringBuilder convert = new StringBuilder();
        char word = str.charAt(0);
        String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
        convert.append(pinyinArray[0].charAt(0));
        return convert.toString().toUpperCase();
    }
}
